/* ----------------------------------------------------------------------------
* File: message_queue_impl.h
*
* Desc: Message queue implementation
*
* Created: 29/05/2011, by Alexey Korshunov
* ---------------------------------------------------------------------------- */
#ifndef _MESSAGE_QUEUE_IMPL_H_
#define _MESSAGE_QUEUE_IMPL_H_

#include "message_queue.h"
#include <memory>
#include <windows.h>
#include <winbase.h>


namespace ModuleManagement
{
	class MessageQueueImpl : public Common::MessageQueue
	{
		struct Node
		{
			Node() : next(NULL)
			{
			}
			Common::MsgInfo data;
			Node* next;
		};

	public:
		MessageQueueImpl();
		~MessageQueueImpl();

		// MessageQueue implementation
		virtual size_t GetCount() const;
		virtual void PutMsg(const Common::MsgInfo& info);
		virtual void GetMsg(Common::MsgInfo& info);
		virtual void Clear();

	private:
		Node* m_top;
		Node* m_cur;
		CRITICAL_SECTION m_Access;
		size_t m_Count;
	};
}
 

#endif // _MESSAGE_QUEUE_IMPL_H_